﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PSE.Framework.Process;
using System.ServiceModel;

namespace PSE.Hosting.ServiceHoster.Business.Services
{
    /// <summary>
    /// Contrato do serviço do Hoster Process
    /// </summary>
    [ServiceContract]
    public interface IServiceHosterPackageService : IProcessService
    {
        /// <summary>
        /// Start all services a specified package.
        /// </summary>
        /// <param name="packageName">The package name to start the services.</param>
        /// <param name="initialize">Initialize the assenblies.</param>
        [OperationContract]
        List<MessageData> StartAll(bool initialize);

        /// <summary>
        /// Stop all the services from an assembly.
        /// </summary>
        /// <param name="packageName">The name of the package containing the assembly to be stopped.</param>
        /// <param name="codeBase">The name of the assembly to be stopped.</param>
        [OperationContract]
        void StopAssembly(string codeBase);

        /// <summary>
        /// Start all WCF services from a specific assembly.
        /// </summary>
        /// <param name="packageName">The name of the package of the assembly to start.</param>
        /// <param name="fileName">The name of the assembly file to start. This is the filename only, without the path.</param>
        /// 
        [OperationContract]
        List<MessageData> StartAssembly(string fileName);

        /// <summary>
        /// Starts a Service configured within the Hoster app.config.
        /// </summary>
        /// <param name="assembly">The assembly name.</param>
        /// <param name="serviceName">The service name to start.</param>
        [OperationContract]
        void StartService(string assembly, string serviceName);

        /// <summary>
        /// Stops the specified service.
        /// </summary>
        /// <param name="packageName">The name of the package containing the service.</param>
        /// <param name="assembly">The assembly name.</param>
        /// <param name="serviceName">The service name to stop.</param>
        [OperationContract]
        void StopService(string assembly, string serviceName);

        /// <summary>
        /// Stops all the services already started from a specific package.
        /// </summary>
        [OperationContract]
        void StopAll();

        /// <summary>
        /// Gets a list of all the services configured within the Service Hoster app.config.
        /// </summary>
        /// <returns></returns>
        [OperationContract]
        List<Entities.Service> GetServiceList(string assembly);

        /// <summary>
        /// Returns a list of all the assemblies added in a package.
        /// </summary>
        /// <param name="packageName">The name of the package to get the list of assenblies.</param>
        /// <returns>List of added assemblies.</returns>
        [OperationContract]
        List<Entities.Assembly> GetAssemblyList();

        /// <summary>
        /// Adds a Service to the Service Hoster config file.
        /// </summary>
        /// <param name="packageName">The name of the package.</param>
        /// <param name="codeBase">The assembly code base.</param>
        /// <param name="domain">The domain name of the user.</param>
        /// <param name="userName">The user name for impersonate service operations.</param>
        /// <param name="password">The user password.</param>
        [OperationContract]
        void AddAssembly(string codeBase);

        /// <summary>
        /// Removes a Service from the Service Hoster config file.
        /// </summary>
        /// <param name="packageName">The name of the package.</param>
        /// <param name="assemblyFile">The name of the assembly file (without path).</param>
        [OperationContract]
        void RemoveAssembly(string assemblyFile);
    }
}
